<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">
  <meta name="description" content="API docs for the run method from the Process class, for the Dart programming language.">
  <title>run method - Process class - dart:io library - Dart API</title>
  <!-- required because all the links are pseudo-absolute -->
  <base href="../..">

  <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500,400i,400,300|Source+Sans+Pro:400,300,700" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="static-assets/github.css">
  <link rel="stylesheet" href="static-assets/styles.css">
  <link rel="icon" href="static-assets/favicon.png">
  
</head>

<body>

<div id="overlay-under-drawer"></div>

<header id="title">
  <button id="sidenav-left-toggle" type="button">&nbsp;</button>
  <ol class="breadcrumbs gt-separated dark hidden-xs">
    <li><a href="index.html">shake</a></li>
    <li><a href="dart-io/dart-io-library.html">dart:io</a></li>
    <li><a href="dart-io/Process-class.html">Process</a></li>
    <li class="self-crumb">run method</li>
  </ol>
  <div class="self-name">run</div>
  <form class="search navbar-right" role="search">
    <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<main>

  <div id="dartdoc-sidebar-left" class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left">
    <header id="header-search-sidebar" class="hidden-l">
      <form class="search-sidebar" role="search">
        <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
      </form>
    </header>
    
    <ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
      <li><a href="index.html">shake</a></li>
      <li><a href="dart-io/dart-io-library.html">dart:io</a></li>
      <li><a href="dart-io/Process-class.html">Process</a></li>
      <li class="self-crumb">run method</li>
    </ol>
    
    <h5>Process class</h5>
    <ol>
      <li class="section-title"><a href="dart-io/Process-class.html#constructors">Constructors</a></li>
      <li><a href="dart-io/Process/Process.html">Process</a></li>
    
      <li class="section-title">
        <a href="dart-io/Process-class.html#instance-properties">Properties</a>
      </li>
      <li><a href="dart-io/Process/exitCode.html">exitCode</a></li>
      <li><a href="dart-io/Process/pid.html">pid</a></li>
      <li><a href="dart-io/Process/stderr.html">stderr</a></li>
      <li><a href="dart-io/Process/stdin.html">stdin</a></li>
      <li><a href="dart-io/Process/stdout.html">stdout</a></li>
      <li class="inherited"><a href="dart-core/Object/hashCode.html">hashCode</a></li>
      <li class="inherited"><a href="dart-core/Object/runtimeType.html">runtimeType</a></li>
    
      <li class="section-title"><a href="dart-io/Process-class.html#instance-methods">Methods</a></li>
      <li><a href="dart-io/Process/kill.html">kill</a></li>
      <li class="inherited"><a href="dart-core/Object/noSuchMethod.html">noSuchMethod</a></li>
      <li class="inherited"><a href="dart-core/Object/toString.html">toString</a></li>
    
      <li class="section-title inherited"><a href="dart-io/Process-class.html#operators">Operators</a></li>
      <li class="inherited"><a href="dart-core/Object/operator_equals.html">operator ==</a></li>
    
    
      <li class="section-title"><a href="dart-io/Process-class.html#static-methods">Static methods</a></li>
      <li><a href="dart-io/Process/killPid.html">killPid</a></li>
      <li><a href="dart-io/Process/run.html">run</a></li>
      <li><a href="dart-io/Process/runSync.html">runSync</a></li>
      <li><a href="dart-io/Process/start.html">start</a></li>
    
    </ol>
  </div><!--/.sidebar-offcanvas-->

  <div id="dartdoc-main-content" class="col-xs-12 col-sm-9 col-md-8 main-content">
      <div><h1>run method</h1></div>

    <section class="multi-line-signature">
      <span class="returntype"><a href="dart-async/Future-class.html">Future</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="dart-io/ProcessResult-class.html">ProcessResult</a></span>&gt;</span></span>
            <span class="name ">run</span>
(<wbr><span class="parameter" id="run-param-executable"><span class="type-annotation"><a href="dart-core/String-class.html">String</a></span> <span class="parameter-name">executable</span>, </span> <span class="parameter" id="run-param-arguments"><span class="type-annotation"><a href="dart-core/List-class.html">List</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="dart-core/String-class.html">String</a></span>&gt;</span></span> <span class="parameter-name">arguments</span>, {</span> <span class="parameter" id="run-param-workingDirectory"><span class="type-annotation"><a href="dart-core/String-class.html">String</a></span> <span class="parameter-name">workingDirectory</span>, </span> <span class="parameter" id="run-param-environment"><span class="type-annotation"><a href="dart-core/Map-class.html">Map</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="dart-core/String-class.html">String</a></span>, <span class="type-parameter"><a href="dart-core/String-class.html">String</a></span>&gt;</span></span> <span class="parameter-name">environment</span>, </span> <span class="parameter" id="run-param-includeParentEnvironment"><span class="type-annotation"><a href="dart-core/bool-class.html">bool</a></span> <span class="parameter-name">includeParentEnvironment</span>: <span class="default-value">true</span>, </span> <span class="parameter" id="run-param-runInShell"><span class="type-annotation"><a href="dart-core/bool-class.html">bool</a></span> <span class="parameter-name">runInShell</span>: <span class="default-value">false</span>, </span> <span class="parameter" id="run-param-stdoutEncoding"><span class="type-annotation"><a href="dart-convert/Encoding-class.html">Encoding</a></span> <span class="parameter-name">stdoutEncoding</span>: <span class="default-value">systemEncoding</span>, </span> <span class="parameter" id="run-param-stderrEncoding"><span class="type-annotation"><a href="dart-convert/Encoding-class.html">Encoding</a></span> <span class="parameter-name">stderrEncoding</span>: <span class="default-value">systemEncoding</span></span> })
      
    </section>
    <section class="desc markdown">
      <p>Starts a process and runs it non-interactively to completion. The
process run is <code>executable</code> with the specified <code>arguments</code>.</p>
<p>Use <code>workingDirectory</code> to set the working directory for the process. Note
that the change of directory occurs before executing the process on some
platforms, which may have impact when using relative paths for the
executable and the arguments.</p>
<p>Use <code>environment</code> to set the environment variables for the process. If not
set the environment of the parent process is inherited. Currently, only
US-ASCII environment variables are supported and errors are likely to occur
if an environment variable with code-points outside the US-ASCII range is
passed in.</p>
<p>If <code>includeParentEnvironment</code> is <code>true</code>, the process's environment will
include the parent process's environment, with <code>environment</code> taking
precedence. Default is <code>true</code>.</p>
<p>If <code>runInShell</code> is true, the process will be spawned through a system
shell. On Linux and OS X, <code>/bin/sh</code> is used, while
<code>%WINDIR%\system32\cmd.exe</code> is used on Windows.</p>
<p>The encoding used for decoding <code>stdout</code> and <code>stderr</code> into text is
controlled through <code>stdoutEncoding</code> and <code>stderrEncoding</code>. The
default encoding is <a href="dart-io/systemEncoding-constant.html">systemEncoding</a>. If <code>null</code> is used no
decoding will happen and the <a href="dart-io/ProcessResult-class.html">ProcessResult</a> will hold binary
data.</p>
<p>Returns a <code>Future&lt;ProcessResult&gt;</code> that completes with the
result of running the process, i.e., exit code, standard out and
standard in.</p>
<p>The following code uses <code>Process.run</code> to grep for <code>main</code> in the
file <code>test.dart</code> on Linux.</p>
<pre class="language-dart"><code>Process.run('grep', ['-i', 'main', 'test.dart']).then((result) {
  stdout.write(result.stdout);
  stderr.write(result.stderr);
});
</code></pre>
    </section>
    
    <section class="summary source-code" id="source">
      <h2><span>Implementation</span></h2>
      <pre class="language-dart"><code class="language-dart">external static Future&lt;ProcessResult&gt; run(
    String executable, List&lt;String&gt; arguments,
    {String workingDirectory,
    Map&lt;String, String&gt; environment,
    bool includeParentEnvironment: true,
    bool runInShell: false,
    Encoding stdoutEncoding: systemEncoding,
    Encoding stderrEncoding: systemEncoding});</code></pre>
    </section>

  </div> <!-- /.main-content -->

  <div id="dartdoc-sidebar-right" class="col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right">
  </div><!--/.sidebar-offcanvas-->

</main>

<footer>
  <span class="no-break">
    shake 0.1.0
  </span>

  
</footer>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="static-assets/typeahead.bundle.min.js"></script>
<script src="static-assets/highlight.pack.js"></script>
<script src="static-assets/URI.js"></script>
<script src="static-assets/script.js"></script>


</body>

</html>
